import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
//导入全局样式表
import './assets/CSS/global.css'

import TreeTable from 'vue-table-with-tree-grid'

import axios from 'axios'

//导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
//导入富文本编辑器对应的样式
import 'quill/dist/quill.core.css' // import styles
import 'quill/dist/quill.snow.css' // for snow theme
import 'quill/dist/quill.bubble.css' // for bubble theme
//将富文本编辑器注册为全局可用组件
Vue.use(VueQuillEditor)

//配置请求路径
let str = "http://120.53.120.229:8888/api/private/v1/ ";

axios.defaults.baseURL = str.split(' ').join('');
//通过axios请求拦截器添加token，保证拥有获取数据的权限
axios.interceptors.request.use(config => {
  // console.log(config);
  //Authorization 授权
  //需要授权的 API ，必须在请求头中使用 `Authorization` 字段提供 `token` 令牌
  config.headers.Authorization = window.sessionStorage.getItem("token");
  return config;
})

Vue.prototype.$http = axios;
// http://www.ysqorz.top:8888/api/private/v1/ sucess  good
//https://shop.iwangwei.top/api/v1/  error
//https://www.liulongbin.top:8888/api/private/v1/login
//http://timemeetyou.com:8889/api/private/v1/     good       
//http://106.53.73.30:8888/api/private/v1/   good
//http://106.12.11.162:8888/api/private/v1/login error
//http://118.31.171.210:8801/api/private/v1/   good
//http://47.108.206.212:9999/api/private/v1/login   success
//http://rambuild.cn:8888/api/private/v1   good
//http://aerowang.cn:6688/api/private/v1/login  sucess
//http://rambuild.cn:8888/api/private/v1       sucess  good
//http://120.53.120.229:8888/api/private/v1/   sucess  good 

//http://120.53.120.229:1921/#/login
Vue.component("tree-table", TreeTable);

Vue.config.productionTip = false


Vue.filter('dataFormat', function(originVal) {
  let time = new Date(originVal);
  let y = time.getFullYear();
  //padStart是字符串(),作用:取前面2位，如果不足2位，用0代替
  let m = (time.getMonth() + 1 + '').padStart(2, '0');
  let d = (time.getDate() + '').padStart(2, '0');
  let h = (time.getHours() + '').padStart(2, '0');
  let mm = (time.getMinutes() + '').padStart(2, '0');
  let s= (time.getSeconds() + '').padStart(2, '0');
  return `${y}-${m}-${d} ${h}:${mm}:${s}`;
})
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
